/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       external_resource.cpp

	$Header: /game/external_resource.cpp $

	$NoKeywords: $

 ************************************************************************/
// external_resource.cpp: implementation of the t_external_resource class.
//
//////////////////////////////////////////////////////////////////////

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "external_resource.h"

#include <fstream>
#include "compressed_buffer.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

t_external_resource::t_external_resource( char const* folder_name, char const* file_name )
{
	m_file_name = folder_name;
	m_file_name += '\\';
	m_file_name += file_name;
}

t_external_resource::~t_external_resource()
{
}

t_streambuf_ptr t_external_resource::get_stream( int offset )
{
	t_shared_ptr<std::filebuf> file( new std::filebuf );

	if (file->open( m_file_name.c_str(), std::ios::in | std::ios::binary ) == 0)
		return t_streambuf_ptr();
	file->pubseekpos( offset );
	return t_streambuf_ptr(new t_inflate_buffer( file ));
}

std::string t_external_resource::get_filename(){return m_file_name;}
